import { baseUrlApi, requestClient, type Result } from '#/api/request';

/** 支付列表 */
export const getPayList = (params?: any) => {
  return requestClient.get<Result>(
    baseUrlApi('/plugin/pay/api_admin_index/index'),
    {
      params,
    },
  );
};

/** 退款 */
export const putPayRefund = (data: object) => {
  return requestClient.put<Result>(
    baseUrlApi('/plugin/pay/api_admin_index/refund'),
    data,
  );
};

/** 发货 */
export const putDelivery = (data: object) => {
  return requestClient.put<Result>(
    baseUrlApi('/plugin/pay/api_admin_index/delivery'),
    data,
  );
};

/** 获取支付设置 */
export const getPaySetting = () => {
  return requestClient.get<Result>(
    baseUrlApi('/plugin/pay/api_admin_setting/index'),
  );
};

/** 提交支付设置 */
export const postPaySetting = (data: object) => {
  return requestClient.post<Result>(
    baseUrlApi('/plugin/pay/api_admin_setting/save'),
    data,
  );
};

/** 收银台结账 */
export const postPayCheckstand = (data: object) => {
  return requestClient.post<Result>(
    baseUrlApi('/plugin/pay/api_admin_checkstand/index'),
    data,
  );
};

/** 查询订单状态 */
export const postFindOrder = (data: object) => {
  return requestClient.post<Result>(
    baseUrlApi('/plugin/pay/index/findOrder'),
    data,
  );
};

/** 商户列表 */
export const getMerchantsList = (params?: any) => {
  return requestClient.get<Result>(
    baseUrlApi('/plugin/pay/api_admin_merchants/index'),
    {
      params,
    },
  );
};

/** 添加商户 */
export const postMerchants = (data: object) => {
  return requestClient.post<Result>(
    baseUrlApi('/plugin/pay/api_admin_merchants/save'),
    data,
  );
};

/** 更新商户 */
export const putMerchants = (data: object) => {
  return requestClient.put<Result>(
    baseUrlApi('/plugin/pay/api_admin_merchants/update'),
    data,
  );
};

/** 更新商户状态 */
export const postMerchantsStatus = (data: object) => {
  return requestClient.post<Result>(
    baseUrlApi('/plugin/pay/api_admin_merchants/status'),
    data,
  );
};

/** 生成商户回调地址 */
export const postMerchantsNotifyUrl = (data: object) => {
  return requestClient.post<Result>(
    baseUrlApi('/plugin/pay/api_admin_merchants/notifyurl'),
    data,
  );
};

/** 更新商户默认状态 */
export const postMerchantsIsDefault = (data: object) => {
  return requestClient.put<Result>(
    baseUrlApi('/plugin/pay/api_admin_merchants/setDefault'),
    data,
  );
};

/** 用户获取商户列表 */
export const getMerchantsListUser = () => {
  return requestClient.get<Result>(
    baseUrlApi('/plugin/pay/api_merchants/index'),
  );
};
